package com.g8.pethospitallearnbackend.mapper;

import com.g8.pethospitallearnbackend.entity.Operation;
import com.g8.pethospitallearnbackend.entity.OperationExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface OperationMapper {
    @SelectProvider(type=OperationSqlProvider.class, method="countByExample")
    long countByExample(OperationExample example);

    @DeleteProvider(type=OperationSqlProvider.class, method="deleteByExample")
    int deleteByExample(OperationExample example);

    @Delete({
        "delete from operation",
        "where op_id = #{opId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String opId);

    @Insert({
        "insert into operation (op_id, role_id, ",
        "flow_id, depart_id, ",
        "op_titile, op_desc, ",
        "op_pic, op_video, ",
        "op_visible, op_order)",
        "values (#{opId,jdbcType=VARCHAR}, #{roleId,jdbcType=VARCHAR}, ",
        "#{flowId,jdbcType=VARCHAR}, #{departId,jdbcType=VARCHAR}, ",
        "#{opTitile,jdbcType=VARCHAR}, #{opDesc,jdbcType=VARCHAR}, ",
        "#{opPic,jdbcType=VARCHAR}, #{opVideo,jdbcType=VARCHAR}, ",
        "#{opVisible,jdbcType=TINYINT}, #{opOrder,jdbcType=INTEGER})"
    })
    int insert(Operation record);

    @InsertProvider(type=OperationSqlProvider.class, method="insertSelective")
    int insertSelective(Operation record);

    @SelectProvider(type=OperationSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="op_id", property="opId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="role_id", property="roleId", jdbcType=JdbcType.VARCHAR),
        @Result(column="flow_id", property="flowId", jdbcType=JdbcType.VARCHAR),
        @Result(column="depart_id", property="departId", jdbcType=JdbcType.VARCHAR),
        @Result(column="op_titile", property="opTitile", jdbcType=JdbcType.VARCHAR),
        @Result(column="op_desc", property="opDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="op_pic", property="opPic", jdbcType=JdbcType.VARCHAR),
        @Result(column="op_video", property="opVideo", jdbcType=JdbcType.VARCHAR),
        @Result(column="op_visible", property="opVisible", jdbcType=JdbcType.TINYINT),
        @Result(column="op_order", property="opOrder", jdbcType=JdbcType.INTEGER)
    })
    List<Operation> selectByExample(OperationExample example);

    @Select({
        "select",
        "op_id, role_id, flow_id, depart_id, op_titile, op_desc, op_pic, op_video, op_visible, ",
        "op_order",
        "from operation",
        "where op_id = #{opId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="op_id", property="opId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="role_id", property="roleId", jdbcType=JdbcType.VARCHAR),
        @Result(column="flow_id", property="flowId", jdbcType=JdbcType.VARCHAR),
        @Result(column="depart_id", property="departId", jdbcType=JdbcType.VARCHAR),
        @Result(column="op_titile", property="opTitile", jdbcType=JdbcType.VARCHAR),
        @Result(column="op_desc", property="opDesc", jdbcType=JdbcType.VARCHAR),
        @Result(column="op_pic", property="opPic", jdbcType=JdbcType.VARCHAR),
        @Result(column="op_video", property="opVideo", jdbcType=JdbcType.VARCHAR),
        @Result(column="op_visible", property="opVisible", jdbcType=JdbcType.TINYINT),
        @Result(column="op_order", property="opOrder", jdbcType=JdbcType.INTEGER)
    })
    Operation selectByPrimaryKey(String opId);

    @UpdateProvider(type=OperationSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Operation record, @Param("example") OperationExample example);

    @UpdateProvider(type=OperationSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Operation record, @Param("example") OperationExample example);

    @UpdateProvider(type=OperationSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Operation record);

    @Update({
        "update operation",
        "set role_id = #{roleId,jdbcType=VARCHAR},",
          "flow_id = #{flowId,jdbcType=VARCHAR},",
          "depart_id = #{departId,jdbcType=VARCHAR},",
          "op_titile = #{opTitile,jdbcType=VARCHAR},",
          "op_desc = #{opDesc,jdbcType=VARCHAR},",
          "op_pic = #{opPic,jdbcType=VARCHAR},",
          "op_video = #{opVideo,jdbcType=VARCHAR},",
          "op_visible = #{opVisible,jdbcType=TINYINT},",
          "op_order = #{opOrder,jdbcType=INTEGER}",
        "where op_id = #{opId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Operation record);
}